home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / GROUPOBJ.PRG < prev    next >
Text File  |  1993-05-04  |  5KB  |  151 lines

  1. PROCEDURE GroupObj
  2. *----------------------------------------------------------------------------
  3. * NAME
  4. *   GroupObj - Group objects together.
  5. *
  6. * DESCRIPTION
  7. *   Takes the current open SCR DBF file and determines the grouping
  8. *   for screen objects based on position and title.  The results
  9. *   are placed into the CURRENTID, NEXTID, and PREVID fields where
  10. *   the value is based on the record number.
  11. *   A group consists of single objects, where GROUPID and CURRENTID
  12. *   have the same value, or a group of objects.  The label field
  13. *   for the group will hold the record numbers for the first and
  14. *   last objects in the group.
  15. *----------------------------------------------------------------------------
  16.  
  17.   SET ORDER TO
  18.   SET FILTER TO
  19.  
  20.   STORE 0 TO ln_last, ln_next, ln_current, ln_groupid
  21.  
  22.   SCAN
  23.  
  24.     IF value_type = "B" .OR. value_type = "T"
  25.       LOOP
  26.     ENDIF
  27.  
  28.     lc_suffix = RIGHT( TRIM( fieldname ), 2 )
  29.  
  30.     DO CASE
  31.       *---------------------------------------------------------
  32.       *-- Check for control labels for comboboxes, entry fields,
  33.       *-- list boxes, radio buttons, and checkboxes
  34.       *---------------------------------------------------------
  35.       CASE lc_suffix = "_0"
  36.  
  37.         ln_groupid = RECNO()
  38.         REPLACE groupid WITH ln_groupid
  39.  
  40.         *------------------------------
  41.         *-- Group all the related items
  42.         *------------------------------
  43.         ln_possuff = AT( "_0", fieldname )
  44.         lc_objname = LEFT( fieldname, ln_possuff )
  45.         ln_next    = 0
  46.         ln_last    = 0
  47.         nMaxLen = 0
  48.         SCAN FOR lc_objname = LEFT( fieldname, ln_possuff ) .AND. ;
  49.                  value_type <> "B" .AND. ;
  50.                  RIGHT( TRIM( fieldname ), 1 ) <> "0"
  51.           ln_current = RECNO()
  52.           IF ln_next = 0
  53.             ln_next = ln_current
  54.           ENDIF
  55.           ln_last = ln_current
  56.  
  57.           REPLACE groupid   WITH ln_groupid
  58.           REPLACE currentid WITH RECNO()
  59.           IF LEFT( fieldname, 3 ) $ "RB_,CK_"
  60.             nMaxLen = MAX( decimals - col, nMaxLen )
  61.           ENDIF
  62.  
  63.         ENDSCAN                          
  64.  
  65.         *---------------------------------------------------------
  66.         *-- Store the group's first and last objects in previd and
  67.         *-- nextid fields.
  68.         *---------------------------------------------------------
  69.         GOTO ln_groupid
  70.         REPLACE previd WITH ln_next
  71.         REPLACE nextid WITH ln_last
  72.  
  73.         *---------------------------------------------------------------
  74.         *-- Make one last scan for the group to adjust length of CB & RB
  75.         *---------------------------------------------------------------
  76.         IF LEFT( fieldname, 3 ) $ "RB_,CK_"
  77.           REPLACE decimals WITH col + nMaxLen ;
  78.              FOR lc_objname = LEFT( fieldname, ln_possuff ) .AND. ;
  79.                  value_type <> "B"                          .AND. ;
  80.                  RIGHT( TRIM( fieldname ), 1 ) <> "0"
  81.         ENDIF
  82.         GOTO ln_groupid
  83.  
  84.       *-----------------------------------------------------------
  85.       *-- Check for single item controls, like buttons, checkboxes
  86.       *-- and objects without titles.
  87.       *-----------------------------------------------------------
  88.       CASE LEFT( lc_suffix, 1 ) <> "_" .AND. LEFT( fieldname, 3 ) <> "TI_"
  89.  
  90.         ln_groupid = RECNO()
  91.         REPLACE currentid WITH ln_groupid
  92.         REPLACE groupid   WITH ln_groupid
  93.  
  94.       CASE lc_suffix = "_1" .AND. ISBLANK( groupid )
  95.         ln_groupid = RECNO()
  96.         REPLACE currentid WITH ln_groupid
  97.         REPLACE groupid   WITH ln_groupid
  98.  
  99.  
  100.     ENDCASE
  101.  
  102.   ENDSCAN
  103.  
  104.   *----------------------------------------------------------
  105.   *-- Now scan the objects that can get focus and fill in the
  106.   *-- NEXTID and PREVID values.
  107.   *----------------------------------------------------------
  108.   SET ORDER TO ObjOrder
  109.   SET FILTER TO .NOT. ISBLANK( currentid )
  110.   GO TOP
  111.   DO WHILE .NOT. EOF()
  112.     nCurr = currentid
  113.  
  114.     *-- Get the previous value
  115.     SKIP -1
  116.     IF BOF()
  117.       GO BOTTOM
  118.       nPrev = currentid
  119.       GO TOP
  120.     ELSE
  121.       nPrev = currentid
  122.       SKIP
  123.     ENDIF
  124.  
  125.     *-- Get the next value
  126.     SKIP
  127.     IF EOF()
  128.       GO TOP
  129.       nNext = currentid
  130.       GO BOTTOM
  131.     ELSE
  132.       nNext = currentid
  133.       SKIP -1
  134.     ENDIF
  135.  
  136.     *-- Store the values
  137.     REPLACE nextid WITH nNext, previd WITH nPrev
  138.  
  139.     SKIP
  140.  
  141.   ENDDO
  142.   SET FILTER TO
  143.   SET ORDER TO
  144.  
  145. RETURN
  146. *-- EOP: GroupObj
  147.  
  148.  
  149. 
  150.